using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using System.Data.SqlClient;
using SpringWaterDataAccess;

namespace client
{
	/// <summary>
	/// Summary description for bloggerrule.
	/// </summary>
	public class bloggerrule : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Button Button2;
		protected System.Web.UI.WebControls.Button Button3;
		protected System.Web.UI.WebControls.Button Button4;
		protected System.Web.UI.WebControls.Button Button5;
		protected System.Web.UI.WebControls.DataList DataList1;
		protected System.Web.UI.WebControls.DropDownList DropDownList1;
		protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;
		protected System.Web.UI.HtmlControls.HtmlForm Form1;

		protected int userID = 0;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			userID = Convert.ToUInt16(Request.QueryString["UserID"]);
			// Put user code to initialize the page here
			if (!IsPostBack) 
			{
				ForumDataAccess da = new ForumDataAccess();

				DataList1.DataSource = da.GetPostDetailByPostID("180");
				DataList1.DataBind();
			}

		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.DataList1.SelectedIndexChanged += new System.EventHandler(this.DataList1_SelectedIndexChanged);
			this.RadioButtonList1.SelectedIndexChanged += new System.EventHandler(this.RadioButtonList1_SelectedIndexChanged);
			this.Button5.Click += new System.EventHandler(this.Button5_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void Button5_Click(object sender, System.EventArgs e)
		{
			ForumDataAccess da = new ForumDataAccess();
			DataSet userDs = da.GetUserByID(userID);
			string userEmail = Convert.ToString(userDs.Tables[0].Rows[0]["Email"]);

		    SQLAccess sql = new SQLAccess();
			
			if (RadioButtonList1.SelectedValue == "ruleno") 
			{
				Response.Redirect("bloggermain.aspx");
			} 
			else 
			{
				try 
				{
				    sql.ChangeUserInfo(userEmail,"", "", "","",DropDownList1.SelectedValue,"");
                    
				    
				} catch (Exception ex) 
				{
					Response.Write("???" + ex.Message);

				}
				
				Response.Redirect("bloggerinput.aspx?UserID=" + Request.QueryString["UserID"]);
			}
		}

		private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		private void DataList1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}
	}
}
